const team = require("../database/team");
const userinfo = require("../database/userinfo");

module.exports = async (req,res)=>{
  const {tCode, tLeader, tMessage} = req.body;

  const obj = {}
  if(tLeader) obj.tLeader = tLeader;
  if(tMessage) obj.tMessage = tMessage;

  await team.updateOne({ tCode: tCode-0 }, obj);

  if( tLeader ){
    await userinfo.updateOne({ userId: tLeader }, { team: tCode });
  }

  res.send({
    code:1,
    msg:"修改成功",
    data:null
  })

}